package com.fckbug.util;

import java.security.MessageDigest;
import java.util.Scanner;

public class JiaMi {
	public static String md5JiaMi(String str) throws Exception{
		String value = null;
		MessageDigest md5 = null;
		try {
			md5 = MessageDigest.getInstance("MD5");
			sun.misc.BASE64Encoder baseEncoder = new sun.misc.BASE64Encoder();
			value = baseEncoder.encode(md5.digest(str.getBytes("utf-8")));
		} catch (Exception ex) {
			ex.printStackTrace();
			throw ex;
		}
		return value;
	}
	
	public static void main(String[] args) {
		try {
			Scanner s = new Scanner(System.in);
			System.out.println("请输入你的明文密码：");
			String pwd = s.nextLine();
			System.out.println("md5加密后："+md5JiaMi(pwd));
		} catch(Exception ex) {
			ex.printStackTrace();
		}
	}
}
